from rest_framework.permissions import BasePermission
from admincharge.models import ChargeAdmin
from rest_framework.response import Response
from rest_framework import status
from rest_framework.exceptions import PermissionDenied

# 调整用户状态
class AdminPermission(BasePermission):
    def has_permission(self, request, view):
        print('user：',request.user)
        username = request.user
        is_super = ChargeAdmin.objects.get(username=username).is_super
        # print(is_super)
        if is_super == '1':
            return True
        raise PermissionDenied()